// pages/components/scrren-menu/scrren-menu.js
Component({

  /**
   * 组件的属性列表]
   * @param { Boolean } ShowScrrenMenu 是否显示筛选项的菜单
   * 
   */
  properties: {
    ShowScrrenMenu: {
      type: Boolean,
      value: false
    },
    data:{
      type:null,
      value:null
    },
    typeSelected:{
      type:null,
      value:null
    },
    itemSelected:{
      type:null,
      value:null
    },
    SectionData:{
      type: null,
      value: null
    },
    RestValue:{
      type: Boolean,
      value: false,
    },
    typeSelected:{
      type: null,
      value: null
    },
    itemSelected:{
      type: null,
      value: null
    }
  },

  /**
   * 组件的初始数据
   * 
   * @Data: ShowActive => 专区的显示或隐藏
   * @Data: ShowActiveItem => 专区的下标
   * 
   */
  data: {
    ShowActive: false,
    ShowActive2:false
  },

  /**
   * 组件的方法列表
   * 
   * @Method: _CBg 背景的方法
   * @Method: _CDropDown 下拉框的事件
   * @Method: _CRset 重置
   * @Mehtod: __CScrrenMenuRight 右按钮事件
   */
  methods: {
    _CBg(e){
      let td = this.data;
      this.setData({
        ShowScrrenMenu: !this.data.ShowScrrenMenu,
        typeSelected: null,
        itemSelected: null,
        typeFilterId: null,
        itemId: null,
        inputValue1: "",
        inputValue2: "",
        min: "",
        max: "",
        offer: "", 
      });

      this.triggerEvent("ScrrenMenuBg", { itemId: td.itemId, typeSelected: td.typeSelected}, {});
    },
    _CDropDown(e) {
      let td = this.data;
      let ShowActiveItem = e.currentTarget.dataset.index;
      td.data[ShowActiveItem].selected = !td.data[ShowActiveItem].selected;
      this.setData({
        data: td.data
      });
    },
    _CRset(){
      this.setData({
        typeSelected: null,
        itemSelected: null,
        typeFilterId:null,
        itemId:null,
        inputValue1: "",
        inputValue2: "",
        min: "",
        max: "",
        offer: "", 
      });
    },
    _CScrrenMenuRight(e) {
      let td = this.data;
      
      this.triggerEvent("confirm", {
        ShowScrrenMenu: td.ShowScrrenMenu,
        typeFilterId: td.typeFilterId,
        offer:td.offer,
        itemId: td.itemId,
        inputValue1: td.inputValue1,
        inputValue2: td.inputValue2        
      }, {});
    },
    _CRestsFilter(e){      
      let td = this.data,offer = e.currentTarget.dataset.offer,typeSelected = e.currentTarget.dataset.item;
      this.setData({
        typeSelected,
        offer:offer || null,
        ShowActive: false,
        typeFilterId:null ,
        itemSelected:"",
        inputValue1: "",
        inputValue2: "",
        typeFilterId:"",
        itemId:""   
      });
    },
    _CTypeFilter(e){
      let td = this.data,
      itemSelected = e.currentTarget.dataset.index,
      typeFilterId = e.currentTarget.dataset.id,
      itemId = e.currentTarget.dataset.itemid;
      
      this.setData({
        itemSelected,
        typeFilterId,
        itemId,
        // inputValue1:"",
        // inputValue2:"",
        ShowActive: true ,
        min: "",
        max:"",
        offer:"",               
      });
    },
    input1(e){
      let td = this.data,
      offer = e.currentTarget.dataset.offer,
      typeSelected = e.currentTarget.dataset.item;

      this.setData({
        inputValue1: e.detail.value,
        typeSelected,
        offer: offer || null,
        // ShowActive: false,
        // typeFilterId: null,
        // itemSelected: "",
        // typeFilterId: "",
        // itemId: ""
      });
    },
    input2(e) {
      let td = this.data,
        offer = e.currentTarget.dataset.offer,
        typeSelected = e.currentTarget.dataset.item;

      this.setData({
        inputValue2: e.detail.value,
        typeSelected,
        offer: offer || null,
        // ShowActive: false,
        // typeFilterId: null,
        // itemSelected: "",
        // typeFilterId: "",
        // itemId: ""
      });
    }
  }
})
